package geez.widget;

import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.MouseListener;
import com.google.gwt.user.client.ui.Widget;
import static geez.widget.Geez.withStyle;

public class GFocusPanel<G extends GFocusPanel> extends FocusPanel {

    public GFocusPanel() {
    }

    public GFocusPanel(Widget child) {
        super(child);
    }

    public G with(Widget widget) {
        add(widget);
        return downcastSelf();
    }

    public G css(String cssClass, String... optionalClasses) {
        withStyle(this, cssClass, optionalClasses);
        return downcastSelf();
    }

    public G id(String id) {
        Geez.withNameAndId(this, id);
        return downcastSelf();
    }

    public G withClickListener(ClickListener clickListener) {
        addClickListener(clickListener);
        return downcastSelf();
    }

    private G downcastSelf() {
        return (G) this;
    }

    public G withMouseListener(MouseListener mouseListener) {
        addMouseListener(mouseListener);
        return downcastSelf();
    }
}
